package com.jsgt.greekfire.dao.viewmodel

import androidx.lifecycle.Observer
import com.jsgt.greekfire.dao.model.NetLoadResult

abstract class NetLoadResultObserver : Observer<NetLoadResult> {

    abstract fun onSuccess()
    abstract fun onError(msg: String?)

    override fun onChanged(t: NetLoadResult?) {
        when (t?.status) {
            NetLoadResult.STATUS_SUCCESS -> {
                onSuccess()
            }
            NetLoadResult.STATUS_FAILED -> {
                onError(t.message)
            }
        }
    }
}